﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace SNSpirit.Documents
{
	/// <summary>
	/// Represent as a rich document with type information.
	/// </summary>
	public class TypedDocument : INotifyPropertyChanged
	{
		/// <summary>
		/// The content of the document。
		/// </summary>
		private object _Content;

		/// <summary>
		/// Get or set the content of the document.
		/// </summary>
		public object Content
		{
			get
			{
				return this._Content;
			}
			set
			{
				this._Content = value;
				this.OnPropertyChanged("Content");
			}
		}
	
		/// <summary>
		/// The type string of the document.
		/// </summary>
		private string _ContentType;

		/// <summary>
		/// Get of set the type string of the document.
		/// </summary>
		public string ContentType
		{
			get
			{
				return this._ContentType;
			}
			set
			{
				this._ContentType = value;
				this.OnPropertyChanged("ContentType");
			}
		}
				

		/// <summary>
		/// Initialize a new instance of <see cref="TypedDocument"/>.
		/// </summary>
		public TypedDocument()
		{
		}

		/// <summary>
		/// Initialize a new instance of <see cref="TypedDocument"/> with specified content and type information.
		/// </summary>
		/// <param name="content">The content of the new document.</param>
		/// <param name="contentType">The type string of the new document.</param>
		public TypedDocument(object content, string contentType)
		{
			this.Content = content;
			this.ContentType = contentType;
		}


		#region INotifyPropertyChanged Members

		/// <summary>
		/// Raises when the value of a property has been changed.
		/// </summary>
		[field: NonSerialized]
		public event PropertyChangedEventHandler PropertyChanged;

		/// <summary>
		/// Raise <see cref="PropertyChanged"/> Event。
		/// </summary>
		/// <param name="propertyName">The name of the property whose value has been changed.</param>
		protected void OnPropertyChanged(string propertyName)
		{
			if (propertyName == null)
			{
				throw new ArgumentNullException("propertyName");
			}

			if (this.PropertyChanged != null)
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}

		#endregion
	}
}
